package com.yunyouyi.cpicture.domain.user.valueobject;

import cn.hutool.core.util.ObjUtil;
import lombok.AllArgsConstructor;
import lombok.Getter;

@Getter
@AllArgsConstructor
public enum UserRoleEnum {
    USER("用户","user"),
    ADMIN("管理","admin");

    private final String text;
    private final String value;

    /**
     * 根据value获取枚举
     * @param value
     * @return 枚举值
     */
    public static UserRoleEnum getEnumByValue(String value){
        if(ObjUtil.isEmpty(value)){
            return null;
        }
        for(UserRoleEnum userRoleEnum : UserRoleEnum.values()){
            if(userRoleEnum.value.equals(value)){
                return userRoleEnum;
            }
        }
        return null;
    }
}
